﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace StringDefs.Tests
{
    using NUnit.Framework;
    using StringDefs.Common;

    [TestFixture]
    public class CommonTests
    {
        [Test]
        public void IsUpperCaseReturnsTrueForUpperCase()
        {
            Assert.AreEqual(true, 'C'.IsUpperCase());
        }
        [Test]
        public void Test_ToggleCase()
        {
            Assert.AreEqual("stringdefs is a great string library", "stringdefs is a great string library".ToUpper().ToggleCase());
        }
        [Test]
        public void IsUpperCaseReturnsFalseForLowerCase()
        {
            Assert.AreEqual(false, 'c'.IsUpperCase());
        }
       

        [Test]
        public void Test_WordReverse()
        {
            Assert.AreEqual("Code Beautiful", Common.WordReverse("Beautiful Code"));
        }
        [Test]
        public void Test_IsSubSequence()
        {
            Assert.AreEqual (true, "ORNAMENTAL".IsSubSequence("ORAL"));
            Assert.AreEqual (true, "ORNAMENTAL".IsSubSequence("RENTAL"));
            Assert.AreEqual (true, "ORNAMENTAL".IsSubSequence("NATAL"));
            Assert.AreEqual (true, "ORNAMENTAL".IsSubSequence("METAL"));
            Assert.AreEqual (false,"ORNAMENTAL".IsSubSequence("NOR"));
            Assert.AreEqual(true, "CHIMPANZEE".IsSubSequence("HMAN"));
            Assert.AreEqual(true, "GGAAGGGGAAAFGSGSSGGSS".IsSubSequence("GAAFGSS"));
            Assert.AreEqual (true,"a0b0c0d0e0f0g0h0i0j0k0l0m0n0o0p0q0r0s0t0u0v0w0x0y0z0".IsSubSequence ("abcdefghijklmnopqrstuvwxyz"));
            Assert.AreEqual(true, "a0b0c0d0e0f0g0h0i0j0k0l0m0n0o0p0q0r0s0t0u0v0w0x0y0z0".IsSubSequence("abcdefghijklmnopqrstuvwxyz"));


        }
        [Test]
        public void Test_InsertDelimiter()
        {
            Assert.AreEqual( "greet-ings", "greetings".InsertDelimiter("-", 5));
            Assert.AreEqual( "gr-ee-ti-ng-s", "greetings".InsertDelimiter("-", 2));
        }

        [Test]
        public void Test_WordCount()
        {
            Assert.AreEqual(4, "World is not enought".WordCount());
        }

        [Test]
        public void Test_Reverse()
        {
            Assert.AreEqual("UMBRELLA", "UMBRELLA".Reverse().Reverse());
        }

        [Test]
        public void Test_SentenceCase()
        {
            Assert.AreEqual ("How to get there? I know. It's so cold!","how to get there? i Know.it's so cold!".SentenceCase ());
        }

        [Test]
        public void Test_StripWhiteSpaces()
        {
            Assert.AreEqual("Bostonnormallyhassnowduringthistimeoftheyear", "Boston normally has snow during this time of the year".StripWhiteSpaces());
        }

        [Test]
        public void Test_NGram()
        {
            List<string> ngrams = new List<string>();
            ngrams.Add("DA");
            ngrams.Add("AD");

            Assert.AreEqual(ngrams, (List<string>) "DAD".NGrams(2));
        }

        [Test]
        public void Test_MultiRemove()
        {
            Assert.AreEqual("Anger is bad", "Anger is seldom due to a good reason and it always cause bad".
                MultiRemove( "a", "seldom", "due", "to", "good", "reason", "and", "it", "always", "cause"));
        }

        [Test]
        [Ignore("there is a problem with this test")]
        public void InitialUpperCaseTest()
        {
            Assert.AreEqual("Hey, How Are You?", "hey, how are you?".InitialUpperCase(' '));
        }

        [Test]
        public void StripCharsTest()
        {
            Assert.AreEqual("This is an ugly sentence", "This! is* an (ugly sentence^".StripChars(new char[] { '!', '*', '(', '^' }));
        }

        [Test]
        public void MultiRemoveTest()
        {
            Assert.AreEqual("Do I make sense?", "Do I and make non sense?".MultiRemove("and", "non"));
        }

        [Test]
        public void UnQuoteTest()
        {
            Assert.AreEqual("I code, therefore Am", "\"I code, therefore Am\"".UnQuote());
        }
    }
}
